package io.renren.modules.recruit_info.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.recruit_info.entity.RecruitmentPositionInforEntity;
import io.renren.modules.recruit_info.service.RecruitmentPositionInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 招聘岗位信息表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-12-30 15:44:44
 */
@RestController
@RequestMapping("recruit_info/recruitmentpositioninfor")
public class RecruitmentPositionInforController {
    @Autowired
    private RecruitmentPositionInforService recruitmentPositionInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("recruit_info:recruitmentpositioninfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recruitmentPositionInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{positionId}")
    @RequiresPermissions("recruit_info:recruitmentpositioninfor:info")
    public R info(@PathVariable("positionId") Long positionId){
        RecruitmentPositionInforEntity recruitmentPositionInfor = recruitmentPositionInforService.getById(positionId);

        return R.ok().put("recruitmentPositionInfor", recruitmentPositionInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("recruit_info:recruitmentpositioninfor:save")
    public R save(@RequestBody RecruitmentPositionInforEntity recruitmentPositionInfor){
        recruitmentPositionInforService.save(recruitmentPositionInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("recruit_info:recruitmentpositioninfor:update")
    public R update(@RequestBody RecruitmentPositionInforEntity recruitmentPositionInfor){
        ValidatorUtils.validateEntity(recruitmentPositionInfor);
        recruitmentPositionInforService.updateById(recruitmentPositionInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("recruit_info:recruitmentpositioninfor:delete")
    public R delete(@RequestBody Long[] positionIds){
        recruitmentPositionInforService.removeByIds(Arrays.asList(positionIds));

        return R.ok();
    }

}
